﻿#pragma once
#include "AstType.h"
#include "SiContext.h"
#include "BlockContext.h"

class AstFunction;
class ClassInstanceType;
class ValueGen;
class CodeGen;

/**
	函数类的实例
*/
class FunctionInstance {
public:
	FunctionInstance(llvm::Function * f = nullptr) : func(f) {}
	std::string name;
	std::vector< std::pair<std::string, AstType*> > parameters;		// 参数表
	AstType* returnType = nullptr;			// 返回值类型
	std::vector<CodeGen*> block;
	bool variable = false;
	ClassInstanceType* object = nullptr;
public:
	llvm::Function* generateCode(llvm::Module*, llvm::LLVMContext& context);
private:
	llvm::Type* makeReturnType(llvm::LLVMContext& context);
private:
	llvm::Function* func;
};												   
